package Member1;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import java.awt.Color;

public class Output extends JPanel {
	private JScrollPane scrollPane;
	private JTextArea textArea;
	private JLabel lblNewLabel;

	Data6[] d;
	
	
	
	/**
	 * Create the panel.
	 */
	public Output() {
		setLayout(null);
		add(getScrollPane());

	}
	
	
	public void setD(Data6[] d){
		this.d = d;
		
		textArea.setText(""); // 모든 데이터 삭제
		for(int i=0;i<d.length;i++){
			if(d[i] == null) continue;
			String str = String.format("%-8s %6d %-10s %-10s %-10s",d[i].name,d[i].age,d[i].address,d[i].phone,d[i].email);
			textArea.append(str);
			textArea.append("\n");
			
		}
	}
	
	
	
	
	
	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 10, 501, 348);
			scrollPane.setViewportView(getTextArea());
			scrollPane.setColumnHeaderView(getLblNewLabel());
		}
		return scrollPane;
	}
	private JTextArea getTextArea() {
		if (textArea == null) {
			textArea = new JTextArea();
			textArea.setBackground(Color.LIGHT_GRAY);
		}
		return textArea;
	}
	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("이름   나이   주소     연락처     이메일");
		}
		return lblNewLabel;
	}
}
